<!DOCTYPE html>
{% load static %}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主页</title>
    <link rel="stylesheet" href="{% static 'plugins/bootstrap-3.4.1-dist/css/bootstrap.min.css' %}">
    <style>
        .account {
            width: 500px;
            border: 1px solid #dddddd;
            height: 370px;

            margin-left: auto;
            margin-right: auto;
            margin-top: 200px;

            padding: 20px 40px;
            border-radius: 30px;
            box-shadow: 6px 6px 6px aqua;
        }
    </style>
</head>
<body>


<div class="bs-docs-header" tabindex="-1" style="text-align:center; background: lemonchiffon">
    <div class="container">
        <h1>我的博客</h1>
        <p>欢迎来到耿子俊创建的博客系统</p>
    </div>
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <ul class="nav navbar-nav" style="margin-left: 50px">
            <li style="font-size: 20px"><a href="/">主页</a></li>
            {% if not a %}  <!--如如果用户没有登录-->
                <li><a href="/login/">登录</a></li>
            {% endif %}
        </ul>
        <ul class="nav navbar-nav navbar-right">
            <li><a href="/register/">注册</a></li>

            {% if a %}  <!--如如果用户已登录-->

                <li class="dropdown" style="margin-right: 60px">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true"
                       aria-expanded="false">{{ request.session.bkuser }} <span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <li><a href="#">个人信息</a></li>
                        <li><a href="#">。。。。</a></li>
                        <li role="separator" class="divider"></li>
                        <li><a href="/logout/">退出</a></li>
                    </ul>
                </li>

            {% endif %}
        </ul>
    </div>

</div>
<br>
<p style="text-align: center;">欢迎{{ request.session.bkuser }}</p>


{% block content %}
    <div class="bs-example" style="width: 1000px;margin: auto">
        <table class="table table-bordered">
            <a type="submit" style="margin-bottom: 10px" class="btn btn-success" href="/title_add/">添加题目</a>
            <form method="get">
                <div style="float: right">
                    <input type="text" name="search" placeholder="搜索"> <input type="submit" value="搜索">
                </div>
            </form>
            <thead>
            <tr>
                <th>id</th>
                <th>名称</th>
                <th>创建时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <form action="" method="post">
                {% csrf_token %}
                {% for i in page %}
                    <tr>
                        <td>{{ i.id }}</td>
                        <td><a href="/nr/{{ i.id }}/">{{ i.title }}<———</a></td>
                        <td>{{ i.date_add|date:'Y-m-d' }}</td>
                        <td>
                            <a href="/title_edit/{{ i.id }}/" class="btn-group">修改</a>
                            <a href="/title_delete?nid={{ i.id }}" class="btn-danger">删除</a>
                        </td>
                    </tr>
                {% endfor %}
            </form>
            </tbody>
        </table>
    </div>

    <div style="text-align: center">
        <a href="?page={{ 1 }}">首页</a>
        {% if page.has_previous %}
            <a href="?page={{ page.previous_page_number }}">上一页</a>
        {% else %}
            上一页
        {% endif %}

        {% for p in paginator.page_range %}
            {% if p == page.number %}
                {{ p }}
            {% else %}
                <a href="?page={{ p }}">{{ p }}</a>
            {% endif %}
        {% endfor %}

        {% if page.has_next %}
            <a href="?page={{ page.next_page_number }}">下一页</a>
        {% else %}
            下一页
        {% endif %}
        <a href="?page={{ last_page }}">尾页</a>
    </div>



{% endblock content %}

<script src="{% static 'js/jquery-3.6.0.min.js' %}"></script>
<script src="{% static 'plugins/bootstrap-3.4.1-dist/js/bootstrap.js' %}"></script>

<script>
    //刷新验证码 绑定事件
    $('#code_img').click(function () {
        $(this)[0].src += '?'
    })
</script>

</body>
</html>